unsigned char txt='a';
unsigned char rx1,rx2,rx3;
unsigned char rx1str[13],rx1strcat[1];
//char stop="Stop!!";

void uart_str(char *s)
{
   while(*s){uart1_write_char(*s++);}
}
void main() {

  ADPCFG = 0xFFFF;
  TRISB=0;PORTB=0;
  TRISD=0xFF;PORTD=0;
  Lcd_Custom_Config(&PORTB, 7,6,5,4, &PORTB, 0,1,2);
  Lcd_Custom_Cmd(Lcd_Cursor_Off);
  Lcd_Custom_Cmd(Lcd_Clear);

  Uart1_Init(9600);
  //Uart1_Init_Advanced(9600, 0, 1);
  //Uart1_Write_Char('s');

  delay_ms(100);
  
  Lcd_Custom_Out(1,1,"Transmit Program");

  while(1)
  {
    portb.f8=1;//if(PORTD.f1=1)

//        if(portd.f0=1)
//        {uart_str("stop");}
        //{
//        Uart1_Write_Char('a');
//        Lcd_Custom_Out(2,1,"Message Sent");
//        delay_ms(100);
//        }
//        if(portd.f1=1)
//        {
//        Uart1_Write_Char('b');
//        Lcd_Custom_Out(2,1,"Message Sent");
//        delay_ms(100);
//        }
//        if(portd.f0=2)
//        {
//        Uart1_Write_Char('c');
//        Lcd_Custom_Out(2,1,"Message Sent");
//        delay_ms(100);
//        }
//        if(portd.f0=3)
//        {
//        Uart1_Write_Char('d');
//        Lcd_Custom_Out(2,1,"Message Sent");
//        delay_ms(100);
//        }

    if (Uart1_Data_Ready())
      {rx1 = Uart1_Read_Char();//}
       rx2 = Uart1_Read_Char();
       rx3 = Uart1_Read_Char();
       Uart1_Write_Char(rx1);
       Uart1_Write_Char(rx2);
       Uart1_Write_Char(rx3);
       lcd_custom_out(2,1,rx1);
    }
    if (Uart1_Data_Ready())
      {rx1 = Uart1_Read_Char();//}
       rx2 = Uart1_Read_Char();
       rx3 = Uart1_Read_Char();
       Uart1_Write_Char(rx1);
       Uart1_Write_Char(rx2);
       Uart1_Write_Char(rx3);
       lcd_custom_out(2,1,rx1);
    }
//    if(rx1)
//    {inttostr(rx1,rx1str);
//      strncpy(rx1strcat,rx1str,1);
//      rx1strcat[1]='\0';
//      Uart1_Write_Char(rx1strcat);
//      lcd_custom_out(2,1,rx1strcat);
//   // if(rx1==txt)
//    // {Lcd_Custom_Out(2,1,"Message Sent");//goto stop;
//     }


   // }
   }
//stop:
//delay_ms(500);
}